/**
 * @file primary_menu.c
 *.c
 *
 */

/*********************
 *      INCLUDES
 *********************/
#include "lv_watch.h"

#if USE_LV_WATCH_PRIMARY_MENU != 0

#include <stdio.h>

/*********************
 *      DEFINES
 *********************/
#define PRIMARY_MENU_APP_NUM_PRE_TAB (4)
/**********************
 *      TYPEDEFS
 **********************/

/**********************
 *  STATIC PROTOTYPES
 **********************/
#if USE_LV_WATCH_LAUNCHER != 0
static lv_obj_t * menu_create(lv_obj_t * tileview, lv_obj_t * ancient_tab, uint16_t id);
static lv_obj_t * menu_add_btn(lv_obj_t * tab, int8_t menu_index, int8_t btn_id, void * btn_src, watchLangTxtId_t txtId, lv_event_cb_t event_cb);
#endif
static void primary_set_default_menu(nv_watch_launcher_t * launcher_info);

#if USE_LV_WATCH_VIDEOCALL == 0
void videocallmain_create(lv_obj_t * btn, lv_event_t e)
{}
#endif
#if USE_LV_WATCH_QRCODE_SCAN == 0
void qrcode_scan_create_event_cb(lv_obj_t * btn, lv_event_t event)
{}
#endif
#if USE_LV_WATCH_COMPASS == 0
void compass_create_event_cb(lv_obj_t * btn, lv_event_t event)
{}
#endif
#if USE_LV_WATCH_MESSAGE == 0
void message_create_event_cb(lv_obj_t * btn, lv_event_t event)
{}
#endif
#if USE_LV_WATCH_TIMER == 0
void timer_create_event_cb(lv_obj_t * btn, lv_event_t event)
{}
#endif
#if USE_LV_WATCH_EXERCISE == 0
void exercise_create_event_cb(lv_obj_t * btn, lv_event_t event)
{}
#endif
#if USE_LV_WATCH_ELEVATION == 0
void elevation_pressure_create_event_cb(lv_obj_t * btn, lv_event_t event)
{}
#endif
#if USE_LV_WATCH_ACTIVITY == 0
void activity_create_event_cb(lv_obj_t * btn, lv_event_t event)
{}
#endif
#if USE_LV_WATCH_EXERCISE_RECORD == 0
void exercise_record_create_event_cb(lv_obj_t * btn, lv_event_t event)
{}
#endif
#if USE_LV_WATCH_QQ == 0
void qq_create_event_cb(lv_obj_t * btn, lv_event_t event)
{}
#endif
#if USE_LV_WATCH_SLEEP == 0
void sleep_create_event_cb(lv_obj_t * btn, lv_event_t event)
{}
#endif
#if USE_LV_WATCH_HEART_RATE == 0
void heart_rate_create_event_cb(lv_obj_t * btn, lv_event_t event)
{}
#endif
#if USE_LV_WATCH_SEARCH_PHONE == 0
void search_phone_create_event_cb(lv_obj_t * btn, lv_event_t event)
{}
#endif
#if USE_LV_WATCH_MAKE_FRIENDS == 0
void make_friends_create_event_cb(lv_obj_t * btn, lv_event_t event)
{}
#endif
#if USE_LV_BARCODE == 0
void barcode_create_event_cb(lv_obj_t * btn, lv_event_t event)
{}
#endif
#if USE_LV_WATCH_AUDIO_PLAYER == 0
void audio_player_create_event_cb(lv_obj_t * btn, lv_event_t event)
{}
#endif
#if USE_LV_WATCH_IMGVIEWER == 0
void imgviewer_create_event_cb(lv_obj_t * btn, lv_event_t event)
{}
#endif
#if USE_LV_WATCH_QRCODE == 0
void qrcode_create_event_cb(lv_obj_t * btn,lv_event_t event)
{}
#endif

/**********************
 *  STATIC VARIABLES
 **********************/
static watch_app_info_t * menu_app = NULL;
static uint8_t watch_menu_app_cnt = 0;
static watch_app_info_t app[] = {
    { ICON_SETTING, WATCH_TEXT_ID_SETTINGS, setting_create_event_cb },
    { ICON_WECHAT, WATCH_TEXT_ID_WECHAT, voice_msg_create_event_cb },
    { ICON_TELEPHONE, WATCH_TEXT_ID_TELEPHONE, phonebook_create_btn_event_cb },
    { ICON_CAMERA, WATCH_TEXT_ID_CAMERA, camera_create_btn_event_cb },//test code
    { ICON_MAKEFRIENDS, WATCH_TEXT_ID_MAKEFRIENDS, make_friends_create_event_cb },
    { ICON_DIALPAD, WATCH_TEXT_ID_DIALPAD, dialpad_create_event_cb },
    { ICON_PRIMARY_QRCODES, WATCH_TEXT_ID_CREATE_QRCODE, qrcode_create_event_cb },
    { ICON_STOPWATCH, WATCH_TEXT_ID_STOPWATCH, stopwatch_create_event_cb },
    { ICON_CALCULATOR, WATCH_TEXT_ID_CALCULATOR, calculator_create_event_cb },
    { ICON_SPORT, WATCH_TEXT_ID_SPORT, sport_create_event_cb },
    { ICON_HEART_RATE, WATCH_TEXT_ID_HEART_RATE, heart_rate_create_event_cb},
    { ICON_VIDEOCALL, WATCH_TEXT_ID_VIDEOCALL, videocallmain_create },
    { ICON_AIKNOWLEDGE, WATCH_TEXT_ID_AIKNOWLEGE, btn_event_cb },
    { ICON_CALENDAR, WATCH_TEXT_ID_CALENDER, calendar_create_event_cb },
    { ICON_BLOODPRESSURE, WATCH_TEXT_ID_BLOODPRESSURE, btn_event_cb },
    { ICON_ALBUM, WATCH_TEXT_ID_ALBUM, album_create_event_cb },
    { ICON_ANSWEREDQUE, WATCH_TEXT_ID_SPEECH_RECOG, speech_recog_create_event_cb },
    { ICON_PRIMARY_BARCODES, WATCH_TEXT_ID_CREATE_BARCODE, barcode_create_event_cb },
    { ICON_MUSIC, WATCH_TEXT_ID_AUDIO_PLAYER, audio_player_create_event_cb },
    { ICON_IMGVIEWER, WATCH_TEXT_ID_IMGVIEWER, imgviewer_create_event_cb },
    { ICON_CAMERA, WATCH_TEXT_ID_QRCODE_SCAN, qrcode_scan_create_event_cb },
    { ICON_TELEPHONE, WATCH_TEXT_ID_CALL_LOG, call_log_create_event_cb },
    { ICON_ALARM, WATCH_TEXT_ID_ALARM, alarm_create_event_cb },
    { ICON_COMPASS, WATCH_TEXT_ID_COMPASS, compass_create_event_cb },
    { ICON_MESSAGE, WATCH_TEXT_ID_MESSAGE, message_create_event_cb },
    { ICON_TIMER, WATCH_TEXT_ID_TIMER, timer_create_event_cb },
    { ICON_SPORT, WATCH_TEXT_ID_EXERCISE, exercise_create_event_cb },
    { ICON_SLEEP, WATCH_TEXT_ID_SLEEP, sleep_create_event_cb },
    { ICON_ELEVATION, WATCH_TEXT_ID_ELEVATION, elevation_pressure_create_event_cb },
    { ICON_ACTIVITY, WATCH_TEXT_ID_ACTIVITY, activity_create_event_cb },
    { ICON_CALENDAR, WATCH_TEXT_ID_EXERCISE_RECORDS, exercise_record_create_event_cb },
    { ICON_SEARCH_PHONE_ONE, WATCH_TEXT_ID_SEARCH_PHONE, search_phone_create_event_cb },
    { ICON_QQ, WATCH_TEXT_ID_QQ, qq_create_event_cb},

};
/**********************
 *      MACROS
 **********************/

/**********************
 *   GLOBAL FUNCTIONS
***********************/
void primary_menu_init(void)
{
    nv_watch_launcher_t launcher_info;
    uint8_t i = 0;
    uint8_t j = 0;
    watch_menu_app_cnt = 0;
    UI_NV_Read_Req(NV_SECTION_UI_LAUNCHER, 0, sizeof(nv_watch_launcher_t), (uint8_t *)&launcher_info);
    for(i = 0; i < WATCH_APP_MAX_COUNT; i++) {
        if(launcher_info.menu_app_show[i] == 1) {
            watch_menu_app_cnt++;
        }
    }
    printf("%s: show app cnt %d\n", __FUNCTION__, watch_menu_app_cnt);
    if(watch_menu_app_cnt == 0) {
        primary_set_default_menu(&launcher_info);
    }
    menu_app = (watch_app_info_t *)lv_mem_alloc(sizeof(watch_app_info_t) * watch_menu_app_cnt);
    for(i = 0; i < WATCH_APP_MAX_COUNT; i++) {
        if(launcher_info.menu_app_show[i] == 1) {
            memcpy(&menu_app[j], &app[i], sizeof(watch_app_info_t));
            j++;
        }
    }
}

void primary_menu_destroy(void)
{
    if(menu_app != NULL) {
        lv_mem_free(menu_app);
        menu_app = NULL;
    }
    watch_menu_app_cnt = 0;
}

void primary_menu_set_app_show(watch_app_type_t app_type, bool show)
{
    nv_watch_launcher_t launcher_info;
    UI_NV_Read_Req(NV_SECTION_UI_LAUNCHER, 0, sizeof(nv_watch_launcher_t), (uint8_t *)&launcher_info);
    if(launcher_info.menu_app_show[app_type] == show) {
        printf("%s:app %d show is %d already\n", __FUNCTION__, app_type, show);
        return;
    }
    launcher_info.menu_app_show[app_type] = show;
    UI_NV_Write_Req(NV_SECTION_UI_LAUNCHER, 0, sizeof(nv_watch_launcher_t), (uint8_t *)&launcher_info);
    lv_watch_go_home();
#if USE_LV_WATCH_LAUNCHER != 0
    launcher_recreate();
#endif
}

#if USE_LV_WATCH_LAUNCHER2 != 0
void primary_menu_btn_event_cb(lv_obj_t * btn, lv_event_t event)
{
    lv_obj_t * img;
    if(LV_EVENT_FOCUSED == event) {
        img = lv_list_get_btn_img(btn);
        lv_img_set_zoom(img, 256);
    } else if(LV_EVENT_DEFOCUSED == event) {
        img = lv_list_get_btn_img(btn);
        lv_img_set_zoom(img, 192);
    } else if(LV_EVENT_CLICKED == event) {
        uint8_t index = lv_obj_get_user_data(btn).user_num;
        menu_app[index].event_cb(btn, event);
    }
}

void primary_menu_create(lv_obj_t * activity_obj)
{
    uint8_t i = 0;
    primary_menu_init();

    if(NULL == activity_obj) {
        lv_watch_activity_ext_t activity_ext;
        memset(&activity_ext, 0, sizeof(lv_watch_activity_ext_t));
        activity_ext.actId = ACT_ID_MENU;
        activity_ext.create = (lv_watch_activity_create_f_t)primary_menu_create;
        activity_ext.prepare_destory = (lv_watch_activity_prepare_destory_f_t)primary_menu_destroy;
        activity_obj = lv_watch_creat_activity_obj(&activity_ext);
    }
    lv_obj_t * obj = lv_watch_obj_create(activity_obj);
    lv_obj_t * menu_list = lv_list_create(obj, NULL);
    lv_obj_set_size(menu_list, lv_obj_get_width(activity_obj), lv_obj_get_height(activity_obj));
    lv_obj_align(menu_list, NULL, LV_ALIGN_CENTER, 0,  0);
    lv_obj_set_style_local_bg_color(menu_list, LV_LIST_PART_BG, LV_STATE_DEFAULT, LV_COLOR_BLACK);
    lv_obj_set_style_local_pad_top(menu_list, LV_LIST_PART_SCROLLABLE, LV_STATE_DEFAULT, LV_HOR_RES / 6);
    lv_obj_set_style_local_pad_inner(menu_list, LV_LIST_PART_SCROLLABLE, LV_STATE_DEFAULT, LV_HOR_RES / 20);
    lv_obj_set_style_local_pad_left(menu_list, LV_LIST_PART_SCROLLABLE, LV_STATE_DEFAULT, LV_VER_RES * 2 / 9);
    lv_obj_set_style_local_pad_right(menu_list, LV_LIST_PART_SCROLLABLE, LV_STATE_DEFAULT, LV_VER_RES * 2 / 9);
    lv_watch_obj_add_element(lv_page_get_scrl(menu_list));
    lv_obj_t * btn;
    lv_obj_t * img;
    for(i = 0; i < watch_menu_app_cnt; i++) {
        btn = lv_list_add_btn(menu_list, (void *)menu_app[i].img_src, (char *)lv_lang_get_text(menu_app[i].txtId));
        lv_watch_set_free_num(btn, i);
        lv_obj_set_event_cb(btn, primary_menu_btn_event_cb);
        lv_obj_set_style_local_pad_inner(btn, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_HOR_RES / 20);
        lv_obj_set_style_local_text_color(btn, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY);
        lv_obj_set_style_local_text_color(btn, LV_BTN_PART_MAIN, LV_STATE_FOCUSED, LV_COLOR_WHITE);
        img = lv_list_get_btn_img(btn);
        lv_img_set_zoom(img, 192);
        lv_watch_obj_add_element(lv_list_get_btn_img(btn));
    }
}
#elif USE_LV_WATCH_LAUNCHER != 0

lv_obj_t * primary_menu_create_all(lv_obj_t * tabview)
{
    return primary_menu_create(tabview, true, -1);
}

lv_obj_t * primary_menu_create_one(lv_obj_t * tabview, int8_t menu_id)
{
    return primary_menu_create(tabview, false, menu_id);
}

uint8_t primary_menu_get_menu_cnt(void)
{
    return (watch_menu_app_cnt + (PRIMARY_MENU_APP_NUM_PRE_TAB - 1)) / PRIMARY_MENU_APP_NUM_PRE_TAB;
}

lv_obj_t * primary_menu_create(lv_obj_t * tileview, bool create_all, int8_t menu_id)
{
    lv_obj_t * tab = NULL;

    /* static add all menus, it need more memory space */
    if(create_all) {
        for(int8_t i = 0; i < watch_menu_app_cnt; i++) {
            //printf("app[%d].txtId = %s\n", i, app[i].txtId);
            int8_t j = i % PRIMARY_MENU_APP_NUM_PRE_TAB;
            int8_t menu_index = i / PRIMARY_MENU_APP_NUM_PRE_TAB;
            int8_t tab_index = 0;
            if(j == 0) {
                /* new a tab */
                if(LAUNCHER_HOR_SLIDING_LOOP_MODE_ENABLE)
                    tab_index = menu_index + 2;
                else
                    tab_index = menu_index + 1;
                tab = menu_create(tileview, NULL, tab_index);
                LV_ASSERT_MEM(tab);
                if(tab == NULL) return NULL;
            }

            menu_add_btn(tab, menu_index, j, (void *)menu_app[i].img_src, menu_app[i].txtId, menu_app[i].event_cb);
        }
        return tab;
    }

    if(menu_id >= 0) {
        /* dymatic add menu, it save memory space */
        for(int8_t i = 0; i < watch_menu_app_cnt; i++) {
            //printf("app[%d].english = %s\n", i, app[i].english);
            int8_t j = i % PRIMARY_MENU_APP_NUM_PRE_TAB;
            int8_t menu_index = i / PRIMARY_MENU_APP_NUM_PRE_TAB;
            if(menu_index < menu_id) continue;
            if(menu_index > menu_id) break;

            if(j == 0) {
                /* new a tab */
                tab = menu_create(tileview, NULL, 0);
                LV_ASSERT_MEM(tab);
                if(tab == NULL) return NULL;
            }
            menu_add_btn(tab, menu_index, j, (void *)menu_app[i].img_src, menu_app[i].txtId, menu_app[i].event_cb);
        }
    }

    return tab;
}
#endif
/**********************
 *   STATIC FUNCTIONS
 **********************/
static void primary_set_default_menu(nv_watch_launcher_t * launcher_info)
{
    launcher_info->menu_app_show[APP_SETTING] = 1;

#if USE_LV_WATCH_VOICE_MSG == 1
    launcher_info->menu_app_show[APP_WECHAT] = 1;
#endif

#if USE_LV_WATCH_PHONEBOOK == 1
    launcher_info->menu_app_show[APP_PHONEBOOK] = 1;
#endif

#if USE_LV_WATCH_CAMERA == 1
    launcher_info->menu_app_show[APP_CAMERA] = 1;
#endif

#if USE_LV_WATCH_MAKE_FRIENDS == 1
    launcher_info->menu_app_show[APP_MAKEFRIENDS] = 1;
#endif

#if USE_LV_WATCH_DIALPAD == 1
    launcher_info->menu_app_show[APP_DIALPAD] = 1;
#endif

#if USE_LV_WATCH_QRCODE == 1
    launcher_info->menu_app_show[APP_QRCODE] = 1;
#endif

#if USE_LV_WATCH_QRCODE_SCAN == 1
    launcher_info->menu_app_show[APP_QRCODESCAN] = 1;
#endif

#if USE_LV_WATCH_STOPWATCH == 1
    launcher_info->menu_app_show[APP_STOPWATCH] = 1;
#endif

#if USE_LV_WATCH_CALCULATOR == 1
    launcher_info->menu_app_show[APP_CALCULATOR] = 1;
#endif

#if USE_LV_WATCH_PEDOMETER == 1
    launcher_info->menu_app_show[APP_SPORT] = 1;
#endif

#if USE_LV_WATCH_HEART_RATE == 1
    launcher_info->menu_app_show[APP_HEARTRATE] = 1;
#endif

#if USE_LV_WATCH_VIDEOCALL == 1
    launcher_info->menu_app_show[APP_VIDEOCALL] = 1;
#endif

#if USE_LV_WATCH_AIKNOWLEDGE == 1
    launcher_info->menu_app_show[APP_AIKNOWLEDGE] = 1;
#endif

#if USE_LV_WATCH_CALENDAR == 1
    launcher_info->menu_app_show[APP_CALENDAR] = 1;
#endif

#if USE_LV_WATCH_ALBUM == 1
    launcher_info->menu_app_show[APP_ALBUM] = 1;
#endif

#if USE_LV_WATCH_SPEECH_RECOG == 1
    launcher_info->menu_app_show[APP_ANSWERDQUE] = 1;
#endif

#if USE_LV_BARCODE == 1
    launcher_info->menu_app_show[APP_BARCODE] = 1;
#endif

#if USE_LV_WATCH_AUDIO_PLAYER == 1
    launcher_info->menu_app_show[APP_MUSIC] = 1;
#endif

#if USE_LV_WATCH_IMGVIEWER == 1
    launcher_info->menu_app_show[APP_IMGVIEWR] = 1;
#endif

#if USE_LV_WATCH_CALL_LOG == 1
    launcher_info->menu_app_show[APP_CALLLOG] = 1;
#endif

#if USE_LV_WATCH_ALARM == 1
    launcher_info->menu_app_show[APP_ALARM] = 1;
#endif

#if USE_LV_WATCH_COMPASS == 1
    launcher_info->menu_app_show[APP_COMPASS] = 1;
#endif

#if USE_LV_WATCH_MESSAGE == 1
    launcher_info->menu_app_show[APP_MESSAGE] = 1;
#endif

#if USE_LV_WATCH_TIMER == 1
    launcher_info->menu_app_show[APP_TIMER] = 1;
#endif

#if USE_LV_WATCH_EXERCISE == 1
    launcher_info->menu_app_show[APP_EXERCISE] = 1;
#endif

#if USE_LV_WATCH_SLEEP == 1
    launcher_info->menu_app_show[APP_SLEEP] = 1;
#endif

#if USE_LV_WATCH_ELEVATION == 1
    launcher_info->menu_app_show[APP_ELEVATION] = 1;
#endif

#if USE_LV_WATCH_ACTIVITY == 1
    launcher_info->menu_app_show[APP_ACTIVITY] = 1;
#endif

#if USE_LV_WATCH_EXERCISE_RECORD == 1
    launcher_info->menu_app_show[APP_EXERCISE_RECORD] = 1;
#endif

#if USE_LV_WATCH_SEARCH_PHONE
    launcher_info->menu_app_show[APP_SEARCH_PHONE] = 1;
#endif

#if USE_LV_WATCH_QQ == 1
    launcher_info->menu_app_show[APP_QQ] = 1;
#endif

    for(uint8_t i = 0; i < WATCH_APP_MAX_COUNT; i++) {
        if(launcher_info->menu_app_show[i] == 1) {
            watch_menu_app_cnt++;
        }
    }
    UI_NV_Write_Req(NV_SECTION_UI_LAUNCHER, 0, sizeof(nv_watch_launcher_t), (uint8_t *)launcher_info);
    printf("%s: add default show app cnt %d\n", __FUNCTION__, watch_menu_app_cnt);
}

#if USE_LV_WATCH_LAUNCHER != 0
static lv_obj_t * menu_add_btn(lv_obj_t * tab, int8_t menu_index, int8_t btn_id, void * btn_src, watchLangTxtId_t txtId, lv_event_cb_t event_cb)
{
    int8_t i = btn_id % PRIMARY_MENU_APP_NUM_PRE_TAB;


    lv_obj_t * cont = lv_obj_get_child(tab, NULL);
    LV_ASSERT_MEM(cont);
    if(cont == NULL) return NULL;

    lv_obj_t * btn;
    btn = lv_imgbtn_create(cont, NULL);
    lv_imgbtn_set_src(btn, LV_BTN_STATE_RELEASED, btn_src);
    lv_imgbtn_set_src(btn, LV_BTN_STATE_PRESSED, btn_src);
    lv_btn_set_checkable(btn, false);

    lv_obj_set_event_cb(btn, event_cb);
    lv_tileview_add_element(lv_obj_get_parent(tab), btn);

    lv_obj_t * label = lv_label_create(cont, NULL);
    lv_obj_add_style(label, LV_LABEL_PART_MAIN, &lv_watch_font20);

#if 0
    //test
    LV_FONT_DECLARE(lv_font_noto_sans_cjk_20_2);
    lv_font_add(&lv_font_dejavu_20, &lv_font_noto_sans_cjk_20_2);
    lv_font_dejavu_20.next_page = NULL;

    static lv_style_t my_style;
    lv_style_copy(&my_style, lv_obj_get_style(label));
    my_style.text.color = LV_COLOR_WHITE;
    my_style.text.font = &lv_font_noto_sans_cjk_20_2;
    lv_obj_set_style(label, &my_style);
#endif

    lv_label_set_long_mode(label, LV_LABEL_LONG_DOT);
    lv_obj_set_size(label, 100, 30);
    lv_label_set_align(label, LV_LABEL_ALIGN_CENTER);
    lv_label_set_text_id(label, txtId);

#if 0
    char str[10] = "";
    snprintf(str, 10, "menu%d", menu_index);
    lv_label_set_text(label, str);
#endif
    lv_obj_set_click(label, false);

    if(i == 0) {
        lv_obj_align(btn, cont, LV_ALIGN_IN_TOP_LEFT, 30, 20);
    } else if(i == 1) {
        lv_obj_align(btn, cont, LV_ALIGN_IN_TOP_RIGHT, -30, 20);
    } else if(i == 2) {
        lv_obj_align(btn, cont, LV_ALIGN_IN_BOTTOM_LEFT, 30, -45);
    } else if(i == 3) {
        lv_obj_align(btn, cont, LV_ALIGN_IN_BOTTOM_RIGHT, -30, -45);
    }

    lv_obj_align(label, btn, LV_ALIGN_OUT_BOTTOM_MID, 0, 5);


    return btn;
}

static lv_obj_t * menu_create(lv_obj_t * tileview, lv_obj_t * ancient_tab, uint16_t id)
{
    if(!tileview) tileview = lv_scr_act();
    lv_obj_t * tab;

    if(ancient_tab == NULL) {
        /* desktop's signal support switch up or down view, all primary menu must be based on it */
        tab = launcher_tileview_add_tile(tileview, id);
    } else {
        //printf("menu_create: lv_tabview_clean ancient_tab=%p\n", ancient_tab);
        lv_tabview_clean_tab(ancient_tab);
        tab = ancient_tab;
    }

    LV_ASSERT_MEM(tab);
    if(tab == NULL) return NULL;

    lv_obj_t * cont = lv_cont_create(tab, NULL);
    LV_ASSERT_MEM(cont);
    if(cont == NULL) return NULL;
    lv_cont_set_layout(cont, LV_LAYOUT_OFF);
    lv_obj_add_style(cont, LV_CONT_PART_MAIN, &lv_style_transp);
    lv_obj_set_width(cont, LV_HOR_RES);
    lv_obj_set_height(cont, LV_VER_RES);
    lv_tileview_add_element(tileview, cont);
    lv_obj_set_click(cont, false);

    return tab;

}
#endif

#endif /*USE_LV_WATCH_PRIMARY_MENU*/
